<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>命令 | CatchAdmin 官网</title>
    <meta name="description" content="">
    <meta name="generator" content="VuePress 1.8.2">
    <style>a[title="站长统计"]{display:none}</style>
    <script data-ad-client="ca-pub-1505209242532150" async="true" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script src="https://v1.cnzz.com/z_stat.php?id=1279921342&amp;web_id=1279921342"></script>
    <meta name="description" content="基于 Thinkphp & Vue 开发的后台管理框架">
    <meta name="keywords" content="catchadmin, 后台管理, 前后端分离, thinkphp后台管理框架, thinkphp前后端分离框架,php, elementui">
    <link rel="preload" href="/assets/css/0.styles.6834c255.css" as="style"><link rel="preload" href="/assets/js/app.d0396f44.js" as="script"><link rel="preload" href="/assets/js/2.1cef47df.js" as="script"><link rel="preload" href="/assets/js/24.06fd96a3.js" as="script"><link rel="prefetch" href="/assets/js/10.483f2013.js"><link rel="prefetch" href="/assets/js/11.981d4461.js"><link rel="prefetch" href="/assets/js/12.95d2c383.js"><link rel="prefetch" href="/assets/js/13.061c2fe0.js"><link rel="prefetch" href="/assets/js/14.ec2753db.js"><link rel="prefetch" href="/assets/js/15.8ba1c321.js"><link rel="prefetch" href="/assets/js/16.f7f0d34c.js"><link rel="prefetch" href="/assets/js/17.aac0bf62.js"><link rel="prefetch" href="/assets/js/18.2e2fe306.js"><link rel="prefetch" href="/assets/js/19.aee304b3.js"><link rel="prefetch" href="/assets/js/20.86a73bc1.js"><link rel="prefetch" href="/assets/js/21.8992c972.js"><link rel="prefetch" href="/assets/js/22.0a78500a.js"><link rel="prefetch" href="/assets/js/23.06342909.js"><link rel="prefetch" href="/assets/js/25.00664d4e.js"><link rel="prefetch" href="/assets/js/26.c3d4b548.js"><link rel="prefetch" href="/assets/js/27.3c6927ad.js"><link rel="prefetch" href="/assets/js/28.74498c0b.js"><link rel="prefetch" href="/assets/js/29.aae1a826.js"><link rel="prefetch" href="/assets/js/3.4d2bdca7.js"><link rel="prefetch" href="/assets/js/30.c7732a2c.js"><link rel="prefetch" href="/assets/js/31.20403043.js"><link rel="prefetch" href="/assets/js/32.7b8e9cfe.js"><link rel="prefetch" href="/assets/js/33.8610da11.js"><link rel="prefetch" href="/assets/js/4.d7b1015b.js"><link rel="prefetch" href="/assets/js/5.ff87de2e.js"><link rel="prefetch" href="/assets/js/6.0e91e688.js"><link rel="prefetch" href="/assets/js/7.ba30e213.js"><link rel="prefetch" href="/assets/js/8.35122549.js"><link rel="prefetch" href="/assets/js/9.081b18e5.js">
    <link rel="stylesheet" href="/assets/css/0.styles.6834c255.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="ant-row"><div class="sidebar-button"><i aria-label="icon: bars" class="anticon anticon-bars"><svg viewBox="0 0 1024 1024" focusable="false" data-icon="bars" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg></i> <span></span></div> <div class="ant-col ant-col-xs-24 ant-col-sm-24 ant-col-md-6 ant-col-lg-5 ant-col-xl-5 ant-col-xxl-4"><a href="/" class="router-link-active no-logo home-link"><!----> <span class="site-name">CatchAdmin 官网</span></a> <div class="search-box mobile-search"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div></div> <div class="ant-col ant-col-xs-0 ant-col-sm-0 ant-col-md-18 ant-col-lg-19 ant-col-xl-19 ant-col-xxl-20"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><ul role="menu" id="nav" class="ant-menu ant-menu-horizontal ant-menu-root ant-menu-light"><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/" class="router-link-active">
          🏠首页
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/docs/">
          📖文档
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item ant-menu-item-selected"><a href="/laravel/" class="router-link-active">
          📖Laravel
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/faq/">
          🤔FAQ
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-item"><a href="/donate/">
          🎉赞助名单
        </a></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="display:none;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>
          🚀仓库地址
        </span><i class="ant-menu-submenu-arrow"></i></div></li><li role="menuitem" class="ant-menu-submenu ant-menu-submenu-horizontal ant-menu-overflowed-submenu" style="visibility:hidden;position:absolute;"><div aria-haspopup="true" class="ant-menu-submenu-title"><span>···</span><i class="ant-menu-submenu-arrow"></i></div></li></ul> <!----></nav></div></div> <!----></header> <aside class="sidebar"><div><div class="ads"><div id="ads_1"><img src="https://cover.kancloud.cn/akasishikelu/thinkphp6!middle"> <span title="基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析">基于 catchadmin 的 Thinkphp 6.0 企业级后台管理开发&amp;源码分析</span></div></div> <div role="separator" id="reset-margin" class="ant-divider ant-divider-horizontal ant-divider-dashed"></div></div> <ul class="sidebar-links"><li><a href="/laravel/" aria-current="page" title="介绍" class="sidebar-link">介绍</a></li><li><a href="/laravel/install.html" title="项目安装" class="sidebar-link">项目安装</a></li><li><a href="/laravel/module.html" title="模块" class="sidebar-link">模块</a></li><li><a href="/laravel/model.html" title="模型" class="sidebar-link">模型</a></li><li><a href="/laravel/console.html" aria-current="page" title="命令" class="active sidebar-link">命令</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/laravel/console.html#创建模块" title="创建模块" class="sidebar-link">创建模块</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#模块控制" title="模块控制" class="sidebar-link">模块控制</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#查看模块" title="查看模块" class="sidebar-link">查看模块</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#创建控制器" title="创建控制器" class="sidebar-link">创建控制器</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#创建模型" title="创建模型" class="sidebar-link">创建模型</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#创建-migrations" title="创建 migrations" class="sidebar-link">创建 migrations</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#刷新-migrations" title="刷新 migrations" class="sidebar-link">刷新 migrations</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#执行-migrations" title="执行 migrations" class="sidebar-link">执行 migrations</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#回滚-migrations" title="回滚 migrations" class="sidebar-link">回滚 migrations</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#创建-seeder" title="创建 seeder" class="sidebar-link">创建 seeder</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#执行-seeder" title="执行 seeder" class="sidebar-link">执行 seeder</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#初始化管理员" title="初始化管理员" class="sidebar-link">初始化管理员</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#地区获取" title="地区获取" class="sidebar-link">地区获取</a></li><li class="sidebar-sub-header"><a href="/laravel/console.html#发布-views-文件" title="发布 views 文件" class="sidebar-link">发布 views 文件</a></li></ul></li><li><a href="/laravel/form.html" title="表单" class="sidebar-link">表单</a></li><li><a href="/laravel/table.html" title="表格组件" class="sidebar-link">表格组件</a></li><li><a href="/laravel/macros.html" title="扩展方法" class="sidebar-link">扩展方法</a></li><li><a href="/laravel/excel.html" title="Excel" class="sidebar-link">Excel</a></li><li><a href="/laravel/issue.html" title="常见问题" class="sidebar-link">常见问题</a></li></ul></aside> <main class="page"> <div class="theme-antdocs-content content__default"><h1 id="命令"><a href="#命令" class="header-anchor">#</a> 命令</h1> <p><code>Laravel</code> 版本的 <code>Command</code> 指令全部以 <code>catch</code> 开头，这样利于开发者使用，不易混乱。</p> <h3 id="查看-catch-的-console"><a href="#查看-catch-的-console" class="header-anchor">#</a> 查看 Catch 的 Console</h3> <div class="language- extra-class"><pre class="language-text"><code>php artisan | grep catch
</code></pre></div><h2 id="创建模块"><a href="#创建模块" class="header-anchor">#</a> 创建模块</h2> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:make:module {moduleName}
</code></pre></div><p>创建模块之后会自动创建以下文件夹和文件，格式如下，这也是约定的格式。</p> <ul><li><code>Http</code> <ul><li><code>Controllers</code></li> <li><code>Requests</code></li></ul></li> <li><code>Models</code></li> <li><code>module.json</code></li> <li><code>ServiceProvider.php</code></li> <li><code>route.php</code></li></ul> <p>几乎和 <code>thinkphp</code> 的模块一致，当然其功能和作用也是一致的。</p> <h2 id="模块控制"><a href="#模块控制" class="header-anchor">#</a> 模块控制</h2> <p>其实就是模块禁用/启用的功能</p> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:control:module
</code></pre></div><h2 id="查看模块"><a href="#查看模块" class="header-anchor">#</a> 查看模块</h2> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:modules
</code></pre></div><h2 id="创建控制器"><a href="#创建控制器" class="header-anchor">#</a> 创建控制器</h2> <ul><li>moduleName 模块名称</li> <li>controllerName 控制器名称</li> <li>modelName 模型名称</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:make:module {moduleName} {controllerName} {modelName}
</code></pre></div><div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>catch 的控制器生成是和模型强绑定的，如果控制器不需要模型的话，那么可以使用 Laravel 自带的 <code>make:controller</code> 创建之后，移植到对应模块下，或者你可以自己手动创建</p></div> <h2 id="创建模型"><a href="#创建模型" class="header-anchor">#</a> 创建模型</h2> <ul><li>module 模块名称</li> <li>model 模型名称，驼峰法命名</li> <li><code>--d</code> 可选项 支持软删除</li> <li><code>--t</code> 表名称 如果不设置，将会将模型的名称转换成<code>snake</code>命名方式作为表名</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:make:model {module} {model} {--d} {--t=}
</code></pre></div><h2 id="创建-migrations"><a href="#创建-migrations" class="header-anchor">#</a> 创建 migrations</h2> <ul><li>module 模块名称</li> <li>name migration 的名称</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:make:migration {module} {name}
</code></pre></div><h2 id="刷新-migrations"><a href="#刷新-migrations" class="header-anchor">#</a> 刷新 migrations</h2> <ul><li>module 模块名称</li> <li><code>--force</code> 强制</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:migrate:fresh {module} {--force}
</code></pre></div><h2 id="执行-migrations"><a href="#执行-migrations" class="header-anchor">#</a> 执行 migrations</h2> <ul><li>module 模块名称</li> <li><code>--force</code> 强制</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:migrate {module} {--force}
</code></pre></div><h2 id="回滚-migrations"><a href="#回滚-migrations" class="header-anchor">#</a> 回滚 migrations</h2> <ul><li>module 模块名称</li> <li><code>--force</code> 强制</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:migrate:rollback {module} {--force}
</code></pre></div><h2 id="创建-seeder"><a href="#创建-seeder" class="header-anchor">#</a> 创建 seeder</h2> <ul><li>module 模块名称</li> <li>name seeder 的名称</li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:make:migration {module} {name}
</code></pre></div><h2 id="执行-seeder"><a href="#执行-seeder" class="header-anchor">#</a> 执行 seeder</h2> <ul><li>module 模块名称</li> <li><code>--class</code> 可选，执行指定的 <code>seeder class</code></li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:db:seed {module} {--class=}
</code></pre></div><h2 id="初始化管理员"><a href="#初始化管理员" class="header-anchor">#</a> 初始化管理员</h2> <p>其实就是在不进入后台的情况，重置管理员信息</p> <ul><li><code>--table</code> 可以指定 <code>table</code></li></ul> <div class="language- extra-class"><pre class="language-text"><code>php artisan catch:init:admin {--table=admin_users}
</code></pre></div><h2 id="地区获取"><a href="#地区获取" class="header-anchor">#</a> 地区获取</h2> <ul><li><code>--rollback</code>可以删除 <code>region</code> 数据</li></ul> <div class="language- extra-class"><pre class="language-text"><code>catch:region {--rollback} 
</code></pre></div><h2 id="发布-views-文件"><a href="#发布-views-文件" class="header-anchor">#</a> 发布 views 文件</h2> <p>如果需要此命令正常工作，首先要做两件事情。</p> <ul><li>设置 <code>config/catch.php</code> 下的配置项  <code>front_views_path</code> 的前端项目地址，必须指定到 <code>views</code> 目录</li> <li>模块下必须要有 <code>views</code> 目录</li></ul> <div class="language-php extra-class"><pre class="language-php"><code>php artisan <span class="token keyword">catch</span><span class="token punctuation">:</span><span class="token argument-name">publish</span><span class="token punctuation">:</span>views
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/catch-admin/document/edit/master/docs/laravel/console.md" target="_blank" rel="noopener noreferrer">在 Github 编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev"><a href="/laravel/model.html" class="prev"><i aria-label="icon: left" class="anticon anticon-left"><svg viewBox="64 64 896 896" focusable="false" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 0 0 0 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg></i>
        模型
      </a></span> <span class="next"><a href="/laravel/form.html">
        表单
        <i aria-label="icon: right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4z"></path></svg></i></a></span></p></div> </main> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.d0396f44.js" defer></script><script src="/assets/js/2.1cef47df.js" defer></script><script src="/assets/js/24.06fd96a3.js" defer></script>
  </body>
</html>